﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace DAL
{
    public class tbNhanVien
    {
        private string manv;

        public string Manv
        {
            get { return manv; }
            set { manv = value; }
        }
        private string tennv;

        public string Tennv
        {
            get { return tennv; }
            set { tennv = value; }
        }
        private string ngaysinh;

        public string Ngaysinh
        {
            get { return ngaysinh; }
            set { ngaysinh = value; }
        }
        private int gioitinh;

        public int Gioitinh
        {
            get { return gioitinh; }
            set { gioitinh = value; }
        }

        private string diachi;

        public string Diachi
        {
            get { return diachi; }
            set { diachi = value; }
        }

        private string email;

        public string Email
        {
            get { return email; }
            set { email = value; }
        }

        private string chucvu;

        public string Chucvu
        {
            get { return chucvu; }
            set { chucvu = value; }
        }
        private string sdt;

        public string Sdt
        {
            get { return sdt; }
            set { sdt = value; }
        }
        
        private string matkhau;

        public string Matkhau
        {
            get { return matkhau; }
            set { matkhau = value; }
        }
        
        private string matkhaumoi;
        public string Matkhaumoi
        {
            get { return matkhaumoi; }
            set { matkhaumoi = value; }
        }

        DBAccess db = new DBAccess();
        public bool dalKiemTraDN()
        {
            bool res = false;
            string query = "KiemTraDN";
            SqlParameter[] param = new SqlParameter[2];
            param[0] = new SqlParameter("@MaNV", Manv);
            param[1] = new SqlParameter("@MatKhau", Matkhau);
            res = db.DoExecuteReader(query, CommandType.StoredProcedure, param);
            return res;
        }

        public DataTable dalHTNhanVien()
        {
            string query = "HienThiNV";
            SqlParameter[] param = new SqlParameter[1];
            param[0]= new SqlParameter("@MaNV", Manv);
            return db.GetDataTable(query, CommandType.StoredProcedure, param);
        }

        public bool dalThemNV()
        {
            bool res = false;
            string query = "ThemNV";
            SqlParameter[] param = new SqlParameter[7];
            param[0] = new SqlParameter("@TenNV", Tennv);
            param[1] = new SqlParameter("@NgaySinh", Ngaysinh);
            param[2] = new SqlParameter("@GioiTinh", Gioitinh);
            param[3] = new SqlParameter("@DiaChi", Diachi);
            param[4] = new SqlParameter("@SoDT", Sdt);
            param[5] = new SqlParameter("@Email", Email);
            param[6] = new SqlParameter("@Matkhau", Matkhau);
            res = db.DoExcecute(query, CommandType.StoredProcedure, param);
            return res;
        }

        public bool dalSuaNV()
        {
            bool res = false;
            string query = "SuaNV";
            SqlParameter[] param = new SqlParameter[7];
            param[0] = new SqlParameter("@TenNV", Tennv);
            param[1] = new SqlParameter("@NgaySinh", Ngaysinh);
            param[2] = new SqlParameter("@GioiTinh", Gioitinh);
            param[3] = new SqlParameter("@DiaChi", Diachi);
            param[4] = new SqlParameter("@SoDT", Sdt);
            param[5] = new SqlParameter("@Email", Email);
            param[6] = new SqlParameter("@MaNV", Manv);
            res = db.DoExcecute(query, CommandType.StoredProcedure, param);
            return res;
        }

        public bool dalTDMatKhau()
        {
            bool res = false;
            string query = "TDMatKhau";
            SqlParameter[] param = new SqlParameter[3];
            param[0] = new SqlParameter("@MaNV", Manv);
            param[1] = new SqlParameter("@MatKhau", Matkhau);
            param[2] = new SqlParameter("@MatKhauMoi", Matkhaumoi);
            res = db.DoExcecute(query, CommandType.StoredProcedure, param);
            return res;
        }
        public bool dalXoaNV()
        {
            bool res = false;
            string query = "XoaNV";
            SqlParameter[] param = new SqlParameter[1];
            param[0] = new SqlParameter("@MaNV", Manv);
            res = db.DoExcecute(query, CommandType.StoredProcedure, param);
            return res;
        }
    }
}
